#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;
const int N = 1e5 + 10;

int n, m;
int A[N], idx;
struct Node
{
    int l, r, cnt;
}node[N * 4 + N *17];
vector<int> nums;
int root[N];

int find(int x){
    return lower_bound(nums.begin(), nums.end(), x) - nums.begin();
}

int build(int l, int r){
    int p = ++idx;
    if(l == r) return p;
    int mid = l + r >> 1;
    node[p].l = build(l, mid), node[p].r = build(mid + 1, r);
    return p;
}

int insert(int p, int l, int r, int x){
    int q = ++idx;
    node[q] = node[p];
    if(l == r){
        node[q].cnt = node[q].cnt + 1;
        return q;
    }

    int mid = l + r >> 1;
    if(x <= mid)node[q].l = insert(node[p].l, l, mid, x);
    else node[q].r = insert(node[p].r, mid + 1, r, x);
    node[q].cnt = node[node[q].l].cnt + node[node[q].r].cnt;

    return q;

}


int query(int q, int p, int l, int r, int k){
    int k1 = node[node[q].l].cnt - node[node[p].l].cnt;

    int mid = l + r >> 1;
    if(l == r) return l;
    if(k <= k1) return query(node[q].l, node[p].l, l, mid, k);
    else return query(node[q].r,  node[p].r, mid + 1, r, k - k1);
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    scanf("%d%d", &n, &m);

    for(int i = 1; i <= n; i ++){
        scanf("%d", &A[i]);
        nums.push_back(A[i]);
    }

    sort(nums.begin(), nums.end());
    nums.erase(unique(nums.begin(), nums.end()), nums.end());
    
    root[0] = build(0, nums.size() - 1);
    for(int i = 1; i <= n; i ++){
        root[i] = insert(root[i - 1], 0, nums.size() - 1, find(A[i]));
    }

    int l, r, k;
    while(m --){
        scanf("%d%d%d", &l, &r, &k);
        printf("%d\n", nums[query(root[r], root[l - 1], 0, nums.size() - 1, k)]);
    }

    return 0;
}